package com.qf.dao.impl;

import com.qf.dao.ManagerDao;
import com.qf.pojo.Manager;
import com.qf.utils.DbUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.SQLException;

/**
 *
 * dao: 访问数据库
 * @author 千锋教育
 * @Company http://www.mobiletrain.org/
 * @Version 1.0
 */
public class ManagerDaoImpl implements ManagerDao {
    @Override
    public Manager select(String username, String pwd) {

        String sql = "select * from empmanager where username= ? and password = ?";
        QueryRunner qr = new QueryRunner();
        try {
            Manager manager = qr.query(DbUtils.getConnection(), sql, new BeanHandler<>(Manager.class),
                    username, pwd);
            return manager;
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }
}
